﻿using SportsStore.WebUI.HtmlHelpers;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System;
using Microsoft.VisualStudio.TestTools.UnitTesting.Web;
using System.Web.Mvc;
using SportsStore.WebUI.Models;

namespace SportsStore.UnitTests
{
    
    
    /// <summary>
    ///This is a test class for PagingHelpersTest and is intended
    ///to contain all PagingHelpersTest Unit Tests
    ///</summary>
    [TestClass()]
    public class PagingHelpersTest
    {
        [TestMethod()]
        public void Can_Generate_Page_Links()
        {
            // Arrange - define an HTML helper - we need to do this 
            // in order to apply the extension method 
            HtmlHelper myHelper = null;

            // Arrange - create PagingInfo data 
            PagingInfo pagingInfo = new PagingInfo
            {
                CurrentPage = 2,
                TotalItems = 28,
                ItemsPerPage = 10
            };

            // Arrange - set up the delegate using a lambda expression
            Func<int, string> pageUrlDelegate = i => "Page" + i;

            //Act
            MvcHtmlString result = myHelper.PageLinks(pagingInfo:pagingInfo, pageUrl:pageUrlDelegate);

            // Assert
            Assert.AreEqual(result.ToString(), @"<a href=""Page1"">1</a><a class=""selected"" href=""Page2"">2</a><a href=""Page3"">3</a>");
        }
    }
}
